package com.example.musicplayer.dialogTools;

import android.app.Dialog;
import android.content.Context;
import android.view.View;

import com.example.musicplayer.R;
import com.example.musicplayer.settings.MusicPlayerSettings;

public abstract class BaseDialog {
    //the text size in dialog
    public static final int TITLE_SIZE = 20;
    public static final int TEXT_SIZE = 16;
    public static final int BUTTON_SIZE = 19;
    protected int mTitleSize = TITLE_SIZE;
    protected int mTextSize = TEXT_SIZE;
    protected int mButtonSize = BUTTON_SIZE;
    protected Context mContext;
    protected Dialog mDialog;
    protected View mDialogView;

    public BaseDialog(Context context) {
        this(context, R.style.NormalDialogStyle);
    }

    public BaseDialog(Context context, int themeResId) {
        this(context, themeResId, R.style.NormalDialogStyle_NoAnim);
    }

    public BaseDialog(Context context, int themeResId, int defaultResId) {
        mContext = context;
        mDialog = new Dialog(context, MusicPlayerSettings.isAnimEffect() ? themeResId : defaultResId);
        mDialog.setCanceledOnTouchOutside(true);
        mDialogView = setDialogView(context);
        mDialog.setContentView(mDialogView);
        setDialogLayout(context);
    }

    protected abstract View setDialogView(Context context);

    protected abstract void setDialogLayout(Context context);

    protected View getDialogView() {
        return mDialogView;
    }

    public Dialog getDialog() {
        return mDialog;
    }

    public void show() {
        if (mDialog != null) {
            mDialog.show();
        }
    }

    public void dismiss() {
        if (mDialog != null) {
            mDialog.dismiss();
        }
    }
}